package com.cloudfun.campusshare.entity;

import com.cloudfun.campusshare.common.constant.RepireResult;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.GenericGenerator;

import javax.persistence.*;

/**
 * Created by Huqin on 2020/4/22
 */
@Data
@Entity
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "repair")
public class RepairEntity extends BaseEntity {

    @Id
    @GenericGenerator(name = "id_uuid", strategy = "uuid")
    @GeneratedValue(generator = "id_uuid")
    @Column(name = "id", nullable = false, unique = true, length = 40)
    private String id;

    @Column(columnDefinition = ("varchar(40) not null comment '用户id'"))
    private String userId;

    @Column(columnDefinition = ("varchar(40) not null comment '设备id'"))
    private String deviceId;

    @JoinColumn(name = "deviceId", referencedColumnName = "id", updatable = false, insertable = false)
    @ManyToOne
    private DeviceEntity deviceEntity;

    @Column(columnDefinition = ("varchar(128) not null comment '故障类型'"))
    private String faultType;

    @Column(columnDefinition = ("varchar(512) not null comment '故障描述'"))
    private String faultDesc;

    @Column(columnDefinition = ("varchar(64) default null comment '处理结果'"))
    @Enumerated(EnumType.STRING)
    private RepireResult repireResult;

    @Column(columnDefinition = ("varchar(64) default null comment '故障处理描述'"))
    private String remark;
}
